using Items;
using UnityEngine;

public class LimitedContainer : Container
{
    [SerializeField]
    private int capacity;
    public int Capacity => capacity;
    public int UsedCapacity { get; private set; }

    public override int CalculateGiveNum(Item item)
    {
        int ret = base.CalculateGiveNum(item);
        int weight = item.weight;
        if (weight <= 0)
            return MaxNum;
        return (Capacity - UsedCapacity) / item.weight;
    }
    public override void Give(Item item, int num)
    {
        base.Give(item, num);
        UsedCapacity += item.weight + num;
    }
    public override void Throw(Item item, int num)
    {
        base.Throw(item, num);
        UsedCapacity -= num * item.weight;
    }
    public override void Clear()
    {
        base.Clear();
        UsedCapacity = 0;
    }
}